package com.atjg.autocat.utils;

import android.app.Service;
import android.content.Context;
import android.media.AudioManager;

public class VolumeUtil {
private AudioManager mAudioManager;

public VolumeUtil(Context context) {
mAudioManager = (AudioManager) context.getSystemService(Service.AUDIO_SERVICE);
}

// 获取最大多媒体音量
public int getMediaMaxVolume() {
return mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
}

// 获取当前多媒体音量
public int getMediaVolume() {
return mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
}

// 设置多媒体音量
public void setMediaVolume(int volume) {
mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, volume, AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI);
}

// 获取最大通话音量
public int getCallMaxVolume() {
return mAudioManager.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL);
}

// 获取当前通话音量
public int getCallVolume() {
return mAudioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL);
}

// 设置通话音量
public void setCallVolume(int volume) {
mAudioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, volume, AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI);
}

// 获取最大系统音量
public int getSystemMaxVolume() {
return mAudioManager.getStreamMaxVolume(AudioManager.STREAM_SYSTEM);
}

// 获取当前系统音量
public int getSystemVolume() {
return mAudioManager.getStreamVolume(AudioManager.STREAM_SYSTEM);
}

// 设置系统音量
public void setSystemVolume(int volume) {
//mAudioManager.setStreamVolume(AudioManager.STREAM_SYSTEM, volume, AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI);
}
}